Constructing a 2D array by appending rows to an empty array